package com.fw.ui.bao;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.fw.service.auditlog.AuditLogService;
import com.fw.service.auditlog.bean.AuditLogBean;
import com.fw.service.bean.SearchCriteriaBean;
import com.fw.service.bean.SearchResultBean;
import com.fw.ui.service.ServiceExecutor;
import com.fw.ui.service.ServiceOrder;

@Component
@Scope(SCOPE_PROTOTYPE)
public class AuditlogBAO extends AbstractBAO implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Autowired
    private AuditLogService auditLogService;

    public AuditLogBean createAuditLog(AuditLogBean auditLogBean) {
	try {
	    ServiceOrder serviceOrder = new ServiceOrder();
	    serviceOrder.setServiceClass(this.auditLogService);
	    serviceOrder.setMethodName("createAuditLog");
	    serviceOrder.setParameterTypes(new Class[] { AuditLogBean.class });
	    serviceOrder.setParameterValues(new Object[] { auditLogBean });

	    ServiceExecutor serviceExecutor = new ServiceExecutor(serviceOrder, timeout);
	    serviceOrder = serviceExecutor.callService();
	    if (serviceOrder.getResultCode() != null && serviceOrder.getResultCode().equals(new Integer(0))) {
		AuditLogBean result = (AuditLogBean) serviceOrder.getReturnValue();
		return result;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
	return null;
    }

    @SuppressWarnings("unchecked")
    public SearchResultBean<AuditLogBean> selectAuditLog(SearchCriteriaBean<AuditLogBean> searchCriteriaBean) {
	try {
	    ServiceOrder serviceOrder = new ServiceOrder();
	    serviceOrder.setServiceClass(this.auditLogService);
	    serviceOrder.setMethodName("selectAuditLog");
	    serviceOrder.setParameterTypes(new Class[] { SearchCriteriaBean.class });
	    serviceOrder.setParameterValues(new Object[] { searchCriteriaBean });

	    ServiceExecutor serviceExecutor = new ServiceExecutor(serviceOrder, timeout);
	    serviceOrder = serviceExecutor.callService();
	    if (serviceOrder.getResultCode() != null && serviceOrder.getResultCode().equals(new Integer(0))) {
		SearchResultBean<AuditLogBean> result = (SearchResultBean<AuditLogBean>) serviceOrder.getReturnValue();
		return result;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
	return null;
    }

}
